/*
 * TCSS 558
 * Distributed HashMap
 * Fall 2013
 * James Marquardt
 * Matt Adams
 * Justin Wong
 */
package model;
import java.io.Serializable;

public final class Entry implements Serializable {

    /**
     * Serializable ID.
     */
    private static final long serialVersionUID = 2365474236222827134L;

    /**
     * The stored value. 
     */
    private Serializable value;
    
    /**
     * The id of this entry. 
     */
    private int id;
    
    /**
     * Constructs Entry object.
     * 
     * @param id ID of this entry.
     * @param value Object stored in this entry.
     */
    public Entry(final int id, final Serializable value) {
        this.id = id;
        this.value = value;
    }

    /**
     * @return Returns the ID.
     */
    public int getID() {
        return this.id;
    }

    /**
     * @return Returns the value.
     */
    public Serializable getValue() {
        return this.value;
    }
    
    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + id;
        //result = prime * result + ((value == null) ? 0 : value.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (!(obj instanceof Entry)) {
            return false;
        }
        Entry entry = (Entry) obj;
        //return (entry.id == this.id) && entry.value.equals(this.value);
        return (entry.id == this.id);
    }

    @Override
    public String toString() {
        return "Entry [value=" + value + ", id=" + id + "]";
    }
}
